document.addEventListener('click', function (event) {
 
    // 在这里处理点击事件

    console.log('点击的元素是innerHTML:', event.target.innerHTML);
    console.log('点击的元素是outerHTML:', event.target.outerHTML);
    console.log('点击的元素是textContent:', event.target.textContent);
    let text = event.target.textContent.replace("\n","").replace(/\s+/g,"");
    console.log("md5=",text)
    const clickInfoMd5Value = CryptoJS.MD5(text).toString();
    console.log(clickInfoMd5Value)


    // 定义正则表达式
    const regex = /[^/]+\.html$/;

    // 使用正则表达式匹配
    const match = window.location.href.match(regex);

    let  urlMd5 = "";
    // 打印结果
    if (match) {
        console.log("HTML 文件名:", match[0]);
        urlMd5 = match[0].replace(".html","");
    } else {
        console.log("未找到 HTML 文件名");
    }
    
    $.get(`http://localhost:3000/api/getUrl/${clickInfoMd5Value}/${urlMd5}`,function(result){
        console.log(result)
        if(result.success == false){
                return;
        }
  
        if(result.data.is_frame == '2'){
          let iframes = document.getElementsByTagName("iframe");

          let index = iframes.length> 0 ? iframes.length -1 : 0
          iframes[index].src = result.data.target_url_md5;
        }else{
            window.location.href= result.data.target_url_md5;
        }
    });
});